#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
'''
@author: yuejl
@application:
@contact: lewyuejian@163.com
@file: models.py
@time: 2021/3/16 0016 23:16
@desc:
'''

from enum import Enum
from pydantic import BaseModel,Field

from typing import Text, Dict, List, Union, Any


Url = Text
Method: Text
Verify = bool
Headers =  Dict[Text, Text]
Cookies = Dict[Text, Text]

class MethodEnum(Text, Enum):
    """
    请求的方法.
    """
    GET = 'GET'
    POST = 'POST'
    PUT = 'PUT'
    DELETE = 'DELETE'

class AddressData(BaseModel):
    client_ip: Text = "N/A"
    client_port: int = 0
    server_ip: Text = "N/A"
    server_port: int = 0

class RequestData(BaseModel):
    """requests.Request model"""

    method: MethodEnum
    url: Url
    params: Dict[Text, Text] = {}
    headers: Headers = {}
    req_json: Union[Dict, List, Text] = Field(None, alias="json")
    data: Union[Text, Dict[Text, Any]] = None
    cookies: Cookies = {}
    timeout: float = 120
    allow_redirects: bool = True
    verify: Verify = False
    upload: Dict = {}  # used for upload files
    address: AddressData = AddressData()

class ReqRespData(BaseModel):
    request: RequestData